<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('教师批改成绩列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input name="reportExperimentId" th:value="${reportExperimentId}" type="hidden"/>
                <input name="reportStuId" th:value="${reportStuId}" type="hidden"/>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:arrange:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:arrange:remove')}]];
    var prefix = ctx + "system/arrange";

    $(function() {
        var options = {
            url: prefix + "/list3",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit3/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "在线实验项目",
            columns: [{
                checkbox: true
            },
                {
                    field: 'reportId',
                    title: '实验报告编号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'experimentName',
                    title: '实验名称'
                },
                {
                    field: 'reportStuName',
                    title: '学生姓名'
                },
                {
                    field: 'reportDate',
                    title: '在线实验时长',
                    formatter: function(value, row, index) {
                        var date=Math.round(parseFloat(value/60)/1000);
                        return date +"分钟";
                    }
                },
                {
                    field: 'score',
                    title: '教师批改',
                    formatter: function(value, row, index) {
                        if(value == 0 || value == null){
                            return '<a class="btn btn-warning btn-xs " href="javascript:void(0)"><i></i>未批改</a>'
                        }else{
                            return value;
                        }
                    }
                },
                {
                    field: 'submitDate',
                    title: '提交日期'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.score == 0 || row.score==null){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="checkScore(\'' + row.reportExperimentId + ',' + row.reportStuId + ',' + row.uuid + '\')"><i class="fa fa-edit"></i>批改</a> ');
                        }else{
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="attention()"><i class="fa fa-edit"></i>批改</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="lookScore(\'' + row.reportExperimentId + ',' + row.reportStuId + ',' + row.uuid + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function attention(){
        $.modal.msgWarning("该实验已被批改，请不要再次点击");
    }

    function checkScore(val){
        var array = new Array();
        array = val.split(",");
        window.location.href = prefix + '/checkScore?reportExperimentId='+array[0]+"&reportStuId="+array[1]+"&uuid="+array[2];
    }

    function lookScore(val){
        var array = new Array();
        array = val.split(",");
        window.location.href = prefix + '/lookScore?reportExperimentId='+array[0]+"&reportStuId="+array[1]+"&uuid="+array[2];
    }
</script>
</body>
</html>